﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Toybox.NicoSharp.Commons.UnitTest
{
	using Extensions;
	using Utilities;

	[TestClass]
	public class Test_Utilities : AbstractTester
	{

		[TestMethod]
		public void Test_TimeUtility()
		{
			int unixTimeTester = 1362063600; //JSTで 2013/03/01
			DateTime dateTimeTester = new DateTime(2013, 03, 01);
			//DateTime dateTimeTester = new DateTime(2013, 03, 01, 0, 0, 0, 0, DateTimeKind.Local);

			int unixTime = dateTimeTester.GetUnixTime();
			Assert.AreEqual(unixTimeTester, unixTime);

			DateTime dateTime = TimeUtility.UnixTimeToDateTime(unixTimeTester);
			Assert.AreEqual(dateTimeTester, dateTime);
		}


		[TestMethod]
		public void Test_NicoWebClient_GetRedirectURL()
		{
			string url = @"http://seiga.nicovideo.jp/comic/1/ep1";
			//string url = @"http://seiga.nicovideo.jp/watch/mg10940";
			string url2 = NicoWebClient.GetRedirectUrl(url, NetworkState.Cookies);
		}

		[TestMethod]
		public void Test_ContentId()
		{
			string id = @"http://seiga.nicovideo.jp/watch/mg10940";

			ContentId cId01 = new ContentId(id);
			ContentId cId02 = new ContentId("mg", "10940");

			Assert.AreEqual(cId01.Prefix, cId02.Prefix);
			Assert.AreEqual(cId01.Digits, cId02.Digits);
		}

		[TestMethod]
		public void Test_CheckList()
		{
			CheckList list = CheckList.Get();
			Assert.IsNotNull(list);
		}

		[TestMethod]
		public void Test_CheckListT1()
		{
			CheckListT1 list = CheckListT1.Get();
			Assert.IsNotNull(list);
		}
	}
}
